﻿Public Class BrowseBuddiesControl
    Private mCurrentNode As Framework.Net.Node
    Private mCurrentNodeShare As Entities.Infos.ShareInfo
    Private mCurrentNodeShareDirectoryCode As String
    Private mWaitingForMessageIdEx As Integer
    Private mEnterBuddyWhenConnected As Entities.Buddy

    Private mCurrentView As CurrentView
    Private Enum CurrentView
        Buddies
        Shares
        Items
    End Enum

    Private Class ImageKeys
        Public Const Folder As String = "f"
        Public Const Movie As String = "m"
        Public Const TVSeries As String = "t"
        Public Const BuddyOnline As String = "bu"
        Public Const BuddyOffline As String = "bo"
        Public Const Share As String = "s"
    End Class

    Public Sub Init()
        mCurrentView = CurrentView.Buddies
        mCurrentNode = Nothing
        mCurrentNodeShare = Nothing

        ImageList1.Images.Add(ImageKeys.Folder, My.Resources.Folder2)
        ImageList1.Images.Add(ImageKeys.Movie, My.Resources.Movie)
        ImageList1.Images.Add(ImageKeys.TVSeries, My.Resources.TV)
        ImageList1.Images.Add(ImageKeys.BuddyOnline, Framework.My.Resources.Buddy_Online)
        ImageList1.Images.Add(ImageKeys.BuddyOffline, Framework.My.Resources.Buddy_Offline)
        ImageList1.Images.Add(ImageKeys.Share, Framework.My.Resources.Share)

        SetupEvents(True)

        UpdateView()
    End Sub
    Public Sub [Stop]()
        SetupEvents(False)
    End Sub
    Private Sub SetupEvents(ByVal startListening As Boolean)
        If startListening Then
            AddHandler Framework.Net.Manager.NodeStatusChangedGUI, AddressOf EventHandler_NodeStatusChanged
            AddHandler Framework.Buddies.Manager.DeletedGUI, AddressOf EventHandler_BuddyDeleted
            AddHandler Framework.Buddies.Manager.UpdatedGUI, AddressOf EventHandler_BuddyUpdated
        Else
            RemoveHandler Framework.Net.Manager.NodeStatusChangedGUI, AddressOf EventHandler_NodeStatusChanged
            RemoveHandler Framework.Buddies.Manager.DeletedGUI, AddressOf EventHandler_BuddyDeleted
            RemoveHandler Framework.Buddies.Manager.UpdatedGUI, AddressOf EventHandler_BuddyUpdated
        End If
    End Sub

    Private Sub EventHandler_BuddyUpdated(ByVal buddy As Entities.Buddy)
        Try
            If mCurrentView = CurrentView.Buddies Then UpdateItem(buddy, False)
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub
    Private Sub EventHandler_BuddyDeleted(ByVal buddy As Entities.Buddy)
        Try
            If mCurrentView = CurrentView.Buddies Then
                For Each clsItem As ListViewItem In ListView1.Items
                    If TypeOf clsItem.Tag Is Entities.Buddy AndAlso CType(clsItem.Tag, Entities.Buddy).Id = buddy.Id Then
                        clsItem.Remove()
                        Exit For
                    End If
                Next
            ElseIf mCurrentNode.Buddy.Id = buddy.Id Then
                mCurrentView = CurrentView.Buddies
                UpdateView()
            End If
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub GetSharesReplyCallback(ByVal inReplyToMessageId As Integer, ByVal node As Framework.Net.Node, ByVal reply As Engine.Commands.GetShares.Reply)
        Try
            If mWaitingForMessageIdEx = inReplyToMessageId Then
                ListView1.BeginUpdate()
                ListView1.Items.Clear()
                ListView1.Groups.Clear()
                ListView1.ShowGroups = True

                For Each clsGroup As Engine.Commands.GetShares.Group In reply.Groups
                    Dim clsLVG As New ListViewGroup
                    clsLVG.Name = clsGroup.Name
                    clsLVG.Header = clsGroup.Name
                    clsLVG.HeaderAlignment = HorizontalAlignment.Left
                    ListView1.Groups.Add(clsLVG)

                    For Each clsShare As Entities.Infos.ShareInfo In clsGroup.Shares
                        With ListView1.Items.Add(clsShare.Name)
                            .SubItems.Add(String.Format("{0}-share", clsShare.ItemTypes))
                            .SubItems.Add(clsShare.TotalItems.ToString)
                            .SubItems.Add(Framework.Misc.ToReadableFileSize(clsShare.TotalSize))
                            .Tag = clsShare
                            .Group = clsLVG
                            Select Case clsShare.ItemTypes
                                Case Entities.ItemType.Movies
                                    .ImageKey = ImageKeys.Movie
                                Case Entities.ItemType.TVSeries
                                    .ImageKey = ImageKeys.TVSeries
                                Case Else
                                    .ImageKey = ImageKeys.Share
                            End Select
                        End With
                    Next
                    For Each clsFilter As Engine.Commands.GetShares.Filter In clsGroup.Filters
                        With ListView1.Items.Add(clsFilter.Name)
                            .SubItems.Add(String.Empty)
                            .SubItems.Add("Filter")
                            .Tag = clsFilter
                            .Group = clsLVG
                        End With
                    Next
                Next
                ListView1.EndUpdate()
                ListView1.Enabled = True
                ListView1.Focus()
                ReselectSavedSelection()
            End If
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub SetupShareItemsColumns(ByVal columns As Generic.List(Of Engine.Commands.GetShareItems.Column))
        Framework.Win.ListViewSupport.SaveListViewColumnsSettings(ListView1)

        ListView1.Columns.Clear()
        For Each clsCol As Engine.Commands.GetShareItems.Column In columns
            Dim udtAlign As HorizontalAlignment = Convert(clsCol.Alignment)
            ListView1.Columns.Add(clsCol.Caption, clsCol.DefaultWidth, udtAlign)
        Next
        Framework.Win.ListViewSupport.RestoreListViewColumnsSettings(ListView1)
    End Sub
    Private Function Convert(ByVal alignment As Engine.Commands.GetShareItems.Column.HorizontalAlignment) As HorizontalAlignment
        Select Case alignment
            Case Engine.Commands.GetShareItems.Column.HorizontalAlignment.Left
                Return HorizontalAlignment.Left
            Case Engine.Commands.GetShareItems.Column.HorizontalAlignment.Center
                Return HorizontalAlignment.Center
            Case Engine.Commands.GetShareItems.Column.HorizontalAlignment.Right
                Return HorizontalAlignment.Right
            Case Else
                Return HorizontalAlignment.Left
        End Select
    End Function
    Private Sub SetupBuddiesColumns()
        Framework.Win.ListViewSupport.SaveListViewColumnsSettings(ListView1)

        ListView1.Columns.Clear()
        ListView1.Columns.Add("Name", 150, HorizontalAlignment.Left)
        Framework.Win.ListViewSupport.RestoreListViewColumnsSettings(ListView1)
    End Sub
    Private Sub SetupSharesColumns()
        Framework.Win.ListViewSupport.SaveListViewColumnsSettings(ListView1)

        ListView1.Columns.Clear()
        ListView1.Columns.Add("Name", 150, HorizontalAlignment.Left)
        ListView1.Columns.Add("Type", 150, HorizontalAlignment.Left)
        ListView1.Columns.Add("Items", 80, HorizontalAlignment.Right)
        ListView1.Columns.Add("Size", 80, HorizontalAlignment.Right)
        Framework.Win.ListViewSupport.RestoreListViewColumnsSettings(ListView1)
    End Sub

    Private Sub GetShareItemsReplyCallback(ByVal inReplyToMessageId As Integer, ByVal node As Framework.Net.Node, ByVal reply As Engine.Commands.GetShareItems.Reply)
        Try
            If mWaitingForMessageIdEx = inReplyToMessageId Then
                ListView1.BeginUpdate()
                ListView1.Items.Clear()
                ListView1.Groups.Clear()

                SetupShareItemsColumns(reply.Columns)

                ListView1.ShowGroups = reply.Groups.Count > 0

                For Each clsGroup As Engine.Commands.GetShareItems.Group In reply.Groups
                    Dim clsLVG As ListViewGroup = Nothing
                    If Not clsGroup.Hidden Then
                        clsLVG = New ListViewGroup
                        clsLVG.Name = clsGroup.Name
                        clsLVG.Header = clsGroup.Name
                        clsLVG.HeaderAlignment = HorizontalAlignment.Left
                        ListView1.Groups.Add(clsLVG)
                    End If

                    For Each clsDirectory As Engine.Commands.GetShareItems.Directory In clsGroup.Directories
                        Dim clsItem As New ListViewItem
                        With clsItem
                            .Text = clsDirectory.Name
                            If clsDirectory.TotalSize = 0 Then
                                .SubItems.Add(clsDirectory.Description)
                            Else
                                .SubItems.Add(Framework.Misc.ToReadableFileSize(clsDirectory.TotalSize))
                            End If
                            .Tag = clsDirectory
                            .ImageKey = ImageKeys.Folder
                            If Not clsGroup.Hidden Then .Group = clsLVG
                        End With
                        ListView1.Items.Add(clsItem)
                    Next

                    For Each clsItem As Engine.Commands.GetShareItems.ItemInfo In clsGroup.Items
                        Dim clsLVI As New ListViewItem
                        With clsLVI
                            If clsItem.Cells IsNot Nothing AndAlso clsItem.Cells.Count > 0 Then
                                .Text = clsItem.Cells(0).ToString
                                For i As Integer = 1 To clsItem.Cells.Count - 1
                                    .SubItems.Add(clsItem.Cells(i).ToString)
                                Next
                            End If
                            .Tag = clsItem
                            If Not clsGroup.Hidden Then .Group = clsLVG
                        End With
                        ListView1.Items.Add(clsLVI)
                    Next
                Next
                ListView1.EndUpdate()
                ListView1.Enabled = True
                ListView1.Focus()
                ReselectSavedSelection()
            End If
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub EventHandler_NodeStatusChanged(ByVal node As Framework.Net.Node)
        Try
            If mCurrentView = CurrentView.Buddies Then
                If node.Buddy IsNot Nothing Then
                    UpdateItem(node.Buddy, False)
                    If mEnterBuddyWhenConnected IsNot Nothing Then
                        If node.IsOnline And node.Buddy.Id = mEnterBuddyWhenConnected.Id Then
                            EnterSelectedBuddy(node)
                        End If
                    End If
                End If
            ElseIf mCurrentNode Is node Then
                StopAllAsynchOperations()
                mCurrentNode = Nothing
                mCurrentView = CurrentView.Buddies
                UpdateView()
            End If
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub StopAllAsynchOperations()
        mEnterBuddyWhenConnected = Nothing
        mWaitingForMessageIdEx = 0
    End Sub

    Private mSelectedItemKeyByPath As New Generic.Dictionary(Of String, String)

    Private Sub SaveCurrentSelection()
        Dim strKey As String = tslCurrentPath.Text.ToLower
        Dim strSelectedKey As String = Nothing
        If ListView1.SelectedItems.Count = 1 Then
            strSelectedKey = GetItemKey(ListView1.SelectedItems(0))
        End If
        If mSelectedItemKeyByPath.ContainsKey(strKey) Then
            mSelectedItemKeyByPath(strKey) = strSelectedKey
        Else
            mSelectedItemKeyByPath.Add(strKey, strSelectedKey)
        End If
    End Sub
    Private Sub ReselectSavedSelection()
        If ListView1.Items.Count > 0 Then
            Dim strKey As String = tslCurrentPath.Text.ToLower
            If mSelectedItemKeyByPath.ContainsKey(strKey) Then
                Dim strSelectKey As String = mSelectedItemKeyByPath(strKey)
                For Each clsItem As ListViewItem In ListView1.Items
                    If GetItemKey(clsItem) = strSelectKey Then
                        clsItem.Selected = True
                        ListView1.FocusedItem = clsItem
                        Exit For
                    End If
                Next
            Else
                ListView1.Items(0).Selected = True
                ListView1.FocusedItem = ListView1.Items(0)
            End If
            'Else
            'ListView1.Items(0).Selected = True
        End If
    End Sub
    Private Function GetItemKey(ByVal listViewItem As ListViewItem) As String
        Dim clsTag As Object = listViewItem.Tag
        If TypeOf clsTag Is Entities.Buddy Then
            Return String.Format("buddy_{0}", CType(clsTag, Entities.Buddy).Id)
        ElseIf TypeOf clsTag Is Engine.Commands.GetShareItems.Directory Then
            Return String.Format("buddy_{0}_shareddir_{1}", mCurrentNode.BuddyId, CType(clsTag, Engine.Commands.GetShareItems.Directory).Code)
        ElseIf TypeOf clsTag Is Engine.Commands.GetShareItems.ItemInfo Then
            Return String.Format("buddy_{0}_item_{1}", mCurrentNode.BuddyId, CType(clsTag, Engine.Commands.GetShareItems.ItemInfo).Id)
        ElseIf TypeOf clsTag Is Entities.Infos.ShareInfo Then
            Return String.Format("buddy_{0}_share_{1}", mCurrentNode.BuddyId, CType(clsTag, Entities.Infos.ShareInfo).Id)
        ElseIf TypeOf clsTag Is Engine.Commands.GetShares.Filter Then
            Return String.Format("buddy_{0}_sharefilter_{1}", mCurrentNode.BuddyId, CType(clsTag, Engine.Commands.GetShares.Filter).Code)
        Else
            Return Nothing
        End If
    End Function

    Private Sub UpdateView()
        StopAllAsynchOperations()
        ListView1.BeginUpdate()
        ListView1.Items.Clear()
        ListView1.Groups.Clear()
        ListView1.ShowGroups = False

        Select Case mCurrentView
            Case CurrentView.Buddies
                SetupBuddiesColumns()
                tslCurrentPath.Text = "Current Path: \"
                ListView1.Groups.Add("ONLINE", "Online")
                ListView1.Groups.Add("OFFLINE", "Not online")
                ListView1.ShowGroups = True
                For Each clsBuddy As Entities.Buddy In Framework.Buddies.Manager.GetAll
                    UpdateItem(clsBuddy, True)
                Next
                ListView1.Enabled = True
                ListView1.Focus()
                ReselectSavedSelection()
            Case CurrentView.Shares
                SetupSharesColumns()
                tslCurrentPath.Text = String.Format("Current Path: \{0}", mCurrentNode.Buddy.NameLocal)
                ListView1.Items.Add("Loading...")
                ListView1.Enabled = False
                mWaitingForMessageIdEx = Engine.Commands.GetShares.SendRequest(mCurrentNode, AddressOf GetSharesReplyCallback, True)
            Case CurrentView.Items
                tslCurrentPath.Text = String.Format("Current Path: \{0}\{1}{2}", mCurrentNode.Buddy.NameLocal, mCurrentNodeShare.Name, mCurrentNodeShareDirectoryCode)
                ListView1.Items.Add("Loading...")
                ListView1.Enabled = False
                mWaitingForMessageIdEx = Engine.Commands.GetShareItems.SendRequest(mCurrentNode, mCurrentNodeShare, mCurrentNodeShareDirectoryCode, AddressOf GetShareItemsReplyCallback, True)
        End Select

        ListView1.EndUpdate()
    End Sub

    ''Private Sub RemoveItem(ByVal client As Framework.Net.Node)
    ''    For Each clsTmpItem As ListViewItem In ListView1.Items
    ''        If CType(clsTmpItem.Tag, Framework.Net.Node) Is client Then
    ''            ListView1.Items.Remove(clsTmpItem)
    ''            Exit For
    ''        End If
    ''    Next
    ''End Sub

    Private Sub UpdateItem(ByVal buddy As Entities.Buddy, ByVal fromLoad As Boolean)
        Dim clsItem As ListViewItem = Nothing
        If Not fromLoad Then
            For Each clsTmpItem As ListViewItem In ListView1.Items
                If CType(clsTmpItem.Tag, Entities.Buddy).Id = buddy.Id Then
                    clsItem = clsTmpItem
                    Exit For
                End If
            Next
        End If
        If clsItem Is Nothing Then
            clsItem = ListView1.Items.Add(String.Empty)
            clsItem.SubItems.Add(String.Empty)
            clsItem.SubItems.Add(String.Empty)
        End If

        Dim clsNode As Framework.Net.Node = Framework.Net.Manager.GetOnlineByBuddyId(buddy.Id)

        clsItem.Text = buddy.NameLocal
        If clsNode IsNot Nothing AndAlso clsNode.IsOnline Then
            clsItem.Group = ListView1.Groups("ONLINE")
            clsItem.ImageKey = ImageKeys.BuddyOnline
        Else
            clsItem.Group = ListView1.Groups("OFFLINE")
            clsItem.ImageKey = ImageKeys.BuddyOffline
        End If
        clsItem.SubItems(1).Text = String.Empty
        clsItem.SubItems(2).Text = String.Empty
        clsItem.Tag = buddy
    End Sub

    Private Sub ListView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListView1.KeyDown
        Try
            Select Case e.KeyCode
                Case Keys.Return, Keys.Enter
                    EventHandler_EnterSelected()
                Case Keys.F5
                    UpdateView()
                Case Keys.Back
                    MoveToParentFolder()
            End Select
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
        EventHandler_EnterSelected()
    End Sub

    Private Sub EventHandler_EnterSelected()
        Try
            SaveCurrentSelection()
            Select Case mCurrentView
                Case CurrentView.Buddies
                    EnterSelectedBuddy()
                Case CurrentView.Shares
                    EnterSelectedShare()
                Case CurrentView.Items
                    EnterSelectedItem()
                Case Else
                    MessageBox.Show(Me.FindForm, "Not implemented!", "Browse", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End Select
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub EnterSelectedItem()
        If ListView1.SelectedItems.Count <> 1 Then Beep() : Return
        Dim clsTag As Object = ListView1.SelectedItems(0).Tag
        If TypeOf clsTag Is Engine.Commands.GetShareItems.Directory Then
            mCurrentNodeShareDirectoryCode = CType(clsTag, Engine.Commands.GetShareItems.Directory).Code
            UpdateView()
        ElseIf TypeOf clsTag Is Engine.Commands.GetShareItems.ItemInfo Then
            Dim clsItem As Engine.Commands.GetShareItems.ItemInfo = CType(clsTag, Engine.Commands.GetShareItems.ItemInfo)
            FViewSharedItemDetails_Remote.Show(Me, mCurrentNode, clsItem)
        End If
    End Sub

    Private Sub EnterSelectedBuddy(Optional ByVal node As Framework.Net.Node = Nothing)
        Dim clsBuddy As Entities.Buddy = Nothing
        If node Is Nothing Then
            If ListView1.SelectedItems.Count <> 1 Then Beep() : Return
            clsBuddy = CType(ListView1.SelectedItems(0).Tag, Entities.Buddy)
            node = Framework.Net.Manager.GetOnlineByBuddyId(clsBuddy.Id)
        End If
        If node IsNot Nothing AndAlso node.IsOnline Then
            mCurrentNode = node
            mCurrentView = CurrentView.Shares
            UpdateView()
        ElseIf clsBuddy IsNot Nothing Then
            Select Case MessageBox.Show(Me, String.Format("{0} is not online! Would you like to attempt to connect?", clsBuddy.NameLocal), "Connect?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                Case DialogResult.Yes
                    Framework.Net.Manager.StartConnect(clsBuddy, False)
                    mEnterBuddyWhenConnected = clsBuddy
            End Select
        End If
    End Sub
    Private Sub EnterSelectedShare()
        If ListView1.SelectedItems.Count <> 1 Then Beep() : Return
        If TypeOf ListView1.SelectedItems(0).Tag Is Entities.Infos.ShareInfo Then
            Dim clsItem As Entities.Infos.ShareInfo = CType(ListView1.SelectedItems(0).Tag, Entities.Infos.ShareInfo)
            mCurrentNodeShare = clsItem
            mCurrentView = CurrentView.Items
            mCurrentNodeShareDirectoryCode = Nothing
            UpdateView()
        ElseIf TypeOf ListView1.SelectedItems(0).Tag Is Engine.Commands.GetShares.Filter Then
            MessageBox.Show(Me, "Support for filters not implemented!")
        End If
    End Sub

    Private Sub MoveToParentFolder()
        SaveCurrentSelection()
        Select Case mCurrentView
            Case CurrentView.Buddies
                Return 'do nothing 
            Case CurrentView.Shares
                mCurrentNode = Nothing
                mCurrentView = CurrentView.Buddies
            Case CurrentView.Items
                If String.IsNullOrEmpty(mCurrentNodeShareDirectoryCode) Then
                    mCurrentNodeShare = Nothing
                    mCurrentView = CurrentView.Shares
                Else
                    Dim iPos As Integer = mCurrentNodeShareDirectoryCode.LastIndexOf("\"c)
                    If iPos <= 0 Then
                        mCurrentNodeShareDirectoryCode = Nothing
                    Else
                        mCurrentNodeShareDirectoryCode = mCurrentNodeShareDirectoryCode.Substring(0, iPos)
                    End If
                End If
            Case Else
                Return
        End Select
        UpdateView()
    End Sub

    Private Sub tsbUpFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbUpFolder.Click
        Try
            MoveToParentFolder()
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub DetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DetailsToolStripMenuItem.Click
        Try
            EventHandler_EnterSelected()
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub ContextMenuStrip1_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
        Try
            Dim blnIsOnlyItemsSelected As Boolean = False
            If ListView1.SelectedItems.Count > 0 Then
                blnIsOnlyItemsSelected = True
                For Each clsItem As ListViewItem In ListView1.SelectedItems
                    If Not TypeOf clsItem.Tag Is Engine.Commands.GetShareItems.ItemInfo Then
                        blnIsOnlyItemsSelected = False
                        Exit For
                    End If
                Next
            End If
            If blnIsOnlyItemsSelected Then
                DetailsToolStripMenuItem.Text = "Details..."
                DetailsToolStripMenuItem.Enabled = True
                DownloadToolStripMenuItem.Enabled = True
            Else
                DownloadToolStripMenuItem.Enabled = False
                DetailsToolStripMenuItem.Text = "Browse"
                DetailsToolStripMenuItem.Enabled = ListView1.SelectedItems.Count = 1
            End If
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub

    Private Sub DownloadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadToolStripMenuItem.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            For Each clsItem As ListViewItem In ListView1.SelectedItems
                Dim clsSharedItem As Engine.Commands.GetShareItems.ItemInfo = TryCast(clsItem.Tag, Engine.Commands.GetShareItems.ItemInfo)
                If clsSharedItem IsNot Nothing Then
                    If Not Manager.StartDownload(Me.FindForm, mCurrentNode, clsSharedItem) Then Exit For
                End If
            Next
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

    End Sub
End Class
